//
//  AboutView.m
//  xpkc
//
//  Created by TopSage iOS on 14-8-19.
//  Copyright (c) 2014年 wanmeizty. All rights reserved.
//

#import "AboutView.h"

@implementation AboutView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self creatView];
    }
    return self;
}
- (void)creatView{
    int detalY;
    
    if (IsIOS7) {
        detalY = 20;
    } else {
        detalY = 0;
    }
    
    
    UIImageView *backImageView = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-SCREEN_WIDTH/1.5)/2, 100, SCREEN_WIDTH/1.5, SCREEN_WIDTH/6)];
    [backImageView setImage:[UIImage imageNamed:@"logoName"]];
    [self addSubview:backImageView];
//    self.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"login_ba"]];
    /**
     *   logo以及倒影设置
     */
    [[self layer] setBackgroundColor:[[UIColor whiteColor] CGColor]];
    
    UIImage *balloon = [UIImage imageNamed:@"logo"];                       //改一下图片名就行了
    
    CALayer *topLayer = [[CALayer alloc] init];
    
    [topLayer setBounds:CGRectMake(0, 0, SCREEN_WIDTH/5, SCREEN_WIDTH/5)];
    
    [topLayer setPosition:CGPointMake(Window_Width/2, SCREEN_WIDTH/3+SCREEN_WIDTH/6+SCREEN_WIDTH/8)];
    
    [topLayer setContents:(id)[balloon CGImage]];
    
    [[self layer] addSublayer:topLayer];
    
    CALayer *reflectionLayer = [[CALayer alloc] init];
    
    [reflectionLayer setBounds:CGRectMake(0, 0, SCREEN_WIDTH/5, SCREEN_WIDTH/5)];
    
    [reflectionLayer setPosition:CGPointMake(Window_Width/2, SCREEN_WIDTH/3+SCREEN_WIDTH/6+SCREEN_WIDTH/8+SCREEN_WIDTH/5-11)];
    
    [reflectionLayer setContents:[topLayer contents]];
    
    [reflectionLayer setValue:[NSNumber numberWithFloat:180.0] forKeyPath:@"transform.rotation.x"];
    
    CAGradientLayer *gradientLayer = [[CAGradientLayer alloc] init];
    
    [gradientLayer setBounds:[reflectionLayer bounds]];
    
    [gradientLayer setPosition:CGPointMake([reflectionLayer bounds].size.width/2, [reflectionLayer bounds].size.height/2)];
    
    [gradientLayer setColors:[NSArray arrayWithObjects: (id)[[UIColor clearColor] CGColor],(id)[[UIColor blackColor] CGColor], nil]];
    
    [gradientLayer setStartPoint:CGPointMake(0.5,0.55)];
    
    [gradientLayer setEndPoint:CGPointMake(0.5,1.8)];
    
    [reflectionLayer setMask:gradientLayer];
    
    [[self layer] addSublayer:reflectionLayer];
    // Do any additional setup after loading the view, typically from a nib.
    /**
     *   学派课程
     */
    _study_label=[[UILabel alloc]initWithFrame:CGRectMake(0, _logo_image.frame.origin.y+SCREEN_WIDTH/3+SCREEN_WIDTH/6+SCREEN_WIDTH/8+SCREEN_WIDTH/5+70, SCREEN_WIDTH, 30)];
    _study_label.font=FONT(20.0f);
    _study_label.backgroundColor=CCOLOR;
    _study_label.textAlignment=NSTextAlignmentCenter;
    _study_label.text=@"学派课程";
    _study_label.textColor=[UIColor greenColor];
    /**
     *   版本
     */
    _title_label=[[UILabel alloc]initWithFrame:RECT(0, _study_label.frame.origin.y+40, SCREEN_WIDTH, 30)];
    _title_label.font=FONT_SYS_NORMAL;
    _title_label.backgroundColor=CCOLOR;
  
    NSString *versionStr = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
    
    if ([versionStr length] == 0)
    {
        versionStr = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    }
    _title_label.textAlignment = NSTextAlignmentCenter;
    _title_label.text=[NSString stringWithFormat:@"iOS版本: %@",versionStr];
    _title_label.textColor=[UIColor blackColor];
    /**
     *   客服电话
     */
    _sub_label=[[UILabel alloc]initWithFrame:RECT(0, self.frame.size.height-40, SCREEN_WIDTH, 30)];
    _sub_label.font=FONT_SYS_LITTLE;
    _sub_label.backgroundColor=CCOLOR;
    _sub_label.text=@"客服电话:4006-343-365   QQ咨询:800025533";
    _sub_label.textAlignment = NSTextAlignmentCenter;
    _sub_label.textColor=[UIColor grayColor];
    
    [self addSubview:_logo_image];
    [self addSubview:_title_label];
    [self addSubview:_sub_label];
    [self addSubview:_study_label];


}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
